package com.zhaopin.netty.tianyuan;

import io.netty.util.concurrent.DefaultEventExecutorGroup;
import io.netty.util.concurrent.EventExecutorGroup;

/**
 * Created by TianYuan on 2018/1/8.
 */
public class NettyExecutorGroup {

    private NettyExecutorGroup() {
        executorGroup = new DefaultEventExecutorGroup(Runtime.getRuntime().availableProcessors() * 2);
    }

    private EventExecutorGroup executorGroup;

    private static NettyExecutorGroup instance;

    public static NettyExecutorGroup getInstance() {
        if (instance == null) {
            synchronized (NettyExecutorGroup.class) {
                if (instance == null) {
                    instance = new NettyExecutorGroup();
                }
            }
        }
        return instance;
    }

    public EventExecutorGroup getExecutorGroup() {
        return executorGroup;
    }
}
